IF EXISTS (SELECT * from dbo.sysobjects WHERE id = object_id(N'[dbo].[SelectProductoDepartamentoByIdDepartamento]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[SelectProductoDepartamentoByIdDepartamento]
GO

CREATE PROCEDURE [dbo].[SelectProductoDepartamentoByIdDepartamento]
(
	@IdDepartamento int
)
AS
BEGIN
	SET NOCOUNT ON

	SELECT
	PD.[IdProducto],
	P.Nombre,
	P.Descripcion,
	P.IdLinea,
	P.Imagen,
	P.Icono,
	PD.[IdDepartamento],
	PD.[Stock],
	PD.[Precio],
	PD.[Estado]
	FROM [ProductoDepartamento] AS PD
	INNER JOIN [Producto] AS P ON PD.IdProducto = P.IdProducto
	WHERE PD.[IdDepartamento] = @IdDepartamento AND PD.Estado = 1 AND P.Estado = 1

	SET NOCOUNT OFF
END

GO
